package org.mx.test;

import org.mx.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.nio.file.Paths;

/**
 * 删除并清理H2数据库文件，便于准备单元测试环境
 *
 * @author : john.peng created on date : 2017/11/28
 */
@SuppressWarnings("javadoc")
public class CleanH2DatabaseFile {
    private static final Logger logger = LoggerFactory.getLogger(CleanH2DatabaseFile.class);

    public static void cleanDataFile(String path) {
        try {
            FileUtils.deleteFile(Paths.get(System.getProperty("user.dir"), path));
        } catch (IOException ex) {
            if (logger.isErrorEnabled()) {
                logger.error("Clean the h2 database file fail.", ex);
            }
        }
    }
}
